#ifndef GAME_H
#define GAME_H

#include "Singleton.h"
#include "Factory.h"
#include "CollisionSystem.h"

#include "../Bullet/src/btBulletDynamicsCommon.h"

#include <map>

class GameState;

typedef void (*CollisionHandler)(GameObject* A, GameObject* B);
typedef std::pair<std::string, std::string> KeyType;
typedef std::map<KeyType, CollisionHandler> CollisionMap;

class Game : public Uncopyable
{
	Game();
	friend class Singleton<Game>;
public:
	~Game();

	void RunGame();
	void Draw();
	void Update();

	void SetGameState(GameState* gs);
	void SetCollisionSystem(CollisionSystem*);

	// game object functions
	void AddGameObject(int id, GameObject* g);
	void UpdateGameObjects();
	void DrawGameObjects();
	void DrawMiniMapGameObjects();
	void DrawMiniMapColourPickObjects();
	void DrawColourPickObjects();
	void HandleCollisions(GameObject* A, GameObject* B);
	bool AddCollisionHandler(const std::string& s1, const std::string& s2, CollisionHandler);

	void ClearGameObjects();
	
private:
	void UpdateCollisions();

private:
	GameState* m_state;
	std::map<int, GameObject*> m_gameObjects;

	CollisionSystem* m_pCollisionSystem;
	CollisionMap m_collisionMap;

};

typedef Singleton<Game> TheGame;

#endif //GAME_H